home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / SOUND / AWECTRL.ZIP / AWE.H next >
Encoding:
C/C++ Source or Header  |  1996-06-05  |  6.1 KB  |  157 lines

  1.     /****************************************/
  2.     /*   Low-level control of the EMU8000     */
  3.     /*        (c) Grinus/ToM,  1996         */
  4.     /****************************************/
  5.  
  6.  
  7. // My Types
  8. typedef unsigned char BYTE;
  9. typedef unsigned int  WORD;
  10. typedef unsigned long DWORD;
  11. #define HBYTE(w) (*((BYTE *)&w + 1))
  12. #define HWORD(l) (*((WORD *)&l + 1))
  13.  
  14.  
  15. /*******************************/
  16. /*      EMU8000 Registers      */
  17. /*******************************/
  18.  
  19. // The low byte of the address is reserved for a G-channel number (0 to 29).
  20.  
  21. #define AWE_CurrPitch  0x0000 /* (00 620) D ... CurrPitch (W) & PitchCounter (W)
  22.  CurrPitch: a linear pitch (0000..FFFF), still sliding to DestPitch.
  23.  */
  24. #define AWE_DP_Rev_Pan 0x0400 /* (20 620) D ... DestPitch (W) & Reverb (B) & RightPan (B)
  25.  DestPitch: a destination value for the CurrPitch (derived from Pitch).
  26.    HINT: It's good to set CurrPitch and DestPitch before starting the note
  27.      to avoid a very short pitch slide, which can appear.
  28.  RightPan: a volume of the right speaker (0..zero, 255..full)
  29.  */
  30. #define AWE_CurrV_FC   0x0800 /* (40 620) D ... CurrVolume (W) & CurrFC (B) & ?? (B)
  31.  CurrVolume: a linear volume, still sliding to DestVolume (0..0xEAC0)
  32.  CurrFilterCutoff: a linear value ([Hz] - 100) / 31.25
  33.  */
  34. #define AWE_DestV_FC   0x0C00 /* (60 620) D ... DestVolume (W) & DestFC (B) & ?? (B)
  35.  DestVolume: a destination value for the CurrVolume (0..0xEAC0)
  36.          (derived from Volume and ENV2).
  37.    HINTS: It can be used to mute the sample immediately after stopping ENV2.
  38.       Read this register to get the current volume envelope value.
  39.  DestFilterCutoff: ...
  40.  */
  41. #define AWE_10            0x1000 /* (80 620) D ... ??? 00000000
  42.  */
  43. #define AWE_14            0x1400 /* (A0 620) D ... ??? 00000000
  44.  */
  45. #define AWE_Pan_Loops  0x1800 /* (C0 620) D ... LeftPan (B) & LoopS (3B)
  46.  LeftPan: a volume of the left speaker (0..zero, 255..full)
  47.  */
  48. #define AWE_Cho_Loope  0x1C00 // (E0 620) D ... Chorus (B) & LoopE (3B)
  49. #define AWE_Flt_Start  0x2000 // (00 A20) D ... FilterQ (4b) & RAMmode (4b) & CurrPos (3B)
  50.  
  51. #define AWE_24            0x2400 // (20 A20) ? ... efect ctrl, RAM access, ...
  52.  
  53. #define AWE_RdAdrD     0x2414 // (34 A20) D ... address for sample RAM reading
  54. #define AWE_WrAdrD     0x2416 // (36 A20) D ... address for sample RAM writing
  55. #define AWE_DataW      0x241A // (3A A20) W ... sample RAM data
  56.  
  57. #define AWE_CLK        0x261B // (3B A22) W ... read Clock Counter (44100Hz)
  58.  
  59. #define AWE_28           0x2800 // (40 A20) W ... efect params
  60. #define AWE_2A         0x2A00 // (40 A22) W ...
  61. #define AWE_2C         0x2C00 // (60 A20) W ...
  62. #define AWE_2E         0x2E00 // (40 A22) W ...  -"-
  63.  
  64. #define AWE_Env2Dly    0x3000 /* (80 A20) W ... ENV2 Delay
  65.  Delay:     0x8000 - [us]/725
  66.  HINT: a description of the envelope parameters is available in ADIP dox.
  67.  */
  68. #define AWE_Env2Ho_Att 0x3200 /* (80 A22) W ... ENV2 Hold & Attack
  69.  HoldTime:    0x7F - [ms]/92
  70.  AttackTime:    11878/[ms] - 1                  ( 00..20 for time>=360ms )
  71.         0x20 + 16 * ln2(360/[ms])    ( 20..7E for time< 360ms )
  72.         0x7F                ( 7F     for time==0ms )
  73.  */
  74. #define AWE_Env2Su_Dcy 0x3400 /* (A0 A20) W ... ENV2 Sustain & Decay
  75.  Sustain:    0x7F - [-dB] * 8 / 6
  76.         7.bit = 0: Note On (to start the sample, ENV, ...)
  77.         7.bit = 1: Note Off (to start the Decay)
  78.  DecayTime:    2 * log(0.5) * log(23756/[ms])    (0x7F...0ms)
  79.         7.bit -> stop ENV2 (to freeze the actual value)
  80.         It has no effect when increasing the volume!
  81.  HINT: Use this register just for NoteOn/NoteOff !
  82.        Do not use it for changing the volume.
  83.  */
  84. #define AWE_Lfo1Dly    0x3600 // (A0 A22) W ... LFO1 Delay
  85. #define AWE_Env1Dly    0x3800 // (C0 A20) W ... ENV1 Delay
  86. #define AWE_Env1Ho_Att 0x3A00 // (C0 A22) W ... ENV1 Hold & Attack
  87. #define AWE_Env1Su_Dcy 0x3C00 // (E0 A20) W ... ENV1 Sustain & Decay
  88. #define AWE_Lfo2Dly    0x3E00 // (E0 A22) W ... LFO2 Delay
  89. #define AWE_Pitch      0x4000 /* (00 E20) W ... Pitch
  90.  Pitch:        57344 - 4096*log(44100/[Hz])
  91.  HINT: This is the main pitch control. Don't use the linear pitch regs!
  92.  */
  93. #define AWE_FC_Vol     0x4400 /* (20 E20) W ... FiltCutoff & Volume
  94.  FiltCutoff:    ([Hz] - 100) / 31.25
  95.  Volume:    [-dB] * 16 / 6     (255 ... silent)
  96.  HINT: This is the main volume control. Don't use the linear volume regs!
  97.  */
  98. #define AWE_Env1tP_tF  0x4800 /* (40 E20) W ... ENV1 ToPitch & ToFilter
  99.  ToPitch:    [cents] * 8 / 75   (signed)
  100.  ToFilter:    [cents] * 8 / 225  (signed)
  101.  */
  102. #define AWE_Lfo1tP_tF  0x4C00 // (60 E20) W ... LFO1 ToPitch & ToFilter
  103. #define AWE_Lfo1tV_F   0x5000 /* (80 E20) W ... LFO1 ToVolume & Freq
  104.  ToVolume:    [dB] * 12 / 128
  105.  Freq:        [Hz] * 21.44 / 256
  106.  */
  107. #define AWE_Lfo2tP_F   0x5400 // (A0 E20) W ... LFO2 ToPitch & Freq
  108. #define AWE_58         0x5800 // (C0 E20) W ... ??? 0000
  109. #define AWE_5C           0x5C00 // (E0 E20) W ... ??? used in Detect()
  110.  
  111.  
  112. /**********************************/
  113. /*   Other EMU8000 definitions    */
  114. /**********************************/
  115.  
  116. #define MINLOOP   4        // the minimal sample loop length
  117. #define ANTICLICK 4        // the number of anti-click samples (at least 3)
  118.  
  119. // Starting address of the sample RAM  (4MB reserved for ROM)
  120. #define TOPRAM   0x200000
  121.  
  122. // Chorus Params
  123. typedef struct {
  124.     WORD    FbkLevel;    // Feedback Level (0xE600-0xE6FF)
  125.     WORD    Delay;        // Delay (0-0x0DA3)  [1/44100 sec]
  126.     WORD    LfoDepth;    // LFO Depth (0xBC00-0xBCFF)
  127.     DWORD    DelayR;        // Right Delay (0-0xFFFFFFFF) [1/256/44100 sec]
  128.     DWORD    LfoFreq;    // LFO Frequency (0-0xFFFFFFFF)
  129.     } CHORUS_TYPE;
  130.  
  131.  
  132.  
  133. /****************************/
  134. /*   Function prototypes    */
  135. /****************************/
  136.  
  137. void  AweWrW(WORD reg, WORD data);
  138. WORD  AweRdW(WORD reg);
  139. void  AweWrD(WORD reg, WORD hdata, WORD ldata);
  140. DWORD AweRdD(WORD reg);
  141. void  AweWait(WORD delay);
  142. int   AweDetect();
  143. void  AweEnableRam(int rmode);
  144. void  AweDisableRam();
  145. int   AweInitHw();
  146. void  AweTerminate();
  147. void  AweChorusType(int type);
  148. void  AweReverbType(int type);
  149. void  AweTrebleBass(int bass, int treble);
  150. void  AweWrBlock(WORD far *buf, WORD num_samps);
  151. void  AweNoteOn(int gChan,
  152.         BYTE Volume, BYTE Pan, BYTE Reverb, BYTE Chorus,
  153.         WORD AwePitch, WORD AweLinPitch,
  154.         DWORD Start, DWORD LoopS, DWORD LoopE );
  155. void  NoteOff(int gChan);
  156. void  CutNote(int gChan);
  157.